<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var sum=0
        var timer
        var count=0
        function start()
        {   
            print("111")
            timer=setInterval(sumPlus,100)
            var div1=document.getElementById("div1")
                function sumPlus()
                {
                    if(count==0){sum++}
                    div1.style.backgroundColor="grey";
                    div1.style.width=sum+"px";
                }
        }
        function stop()
        {   
            count=1
        }
    </script>
<input type="button" value="开始" onclick="start()">
<input type="button" value="结束" onclick="stop()">
<div id="div1" style="height: 20px;"></div>
</body>
</html>